package structure.algorithm;

/**
 * 平面图形
 * @author fidel
 */
public class PlaneGraphics {
    public static final int MAGNIFICATION = 2;
    /**
     * 打印等腰三角形
     * @param height 此平面图形占据的行数目
     */
    public static void isoscelesTriangle(int height) {
        // row表示当前行
        for (int row = 1; row <= height; row++) {
            // space表示每行打印的空格数量，每次减1
            for (int space = 0; space < height - row; space++) {
                System.out.print(" ");
            }
            // count表示每行打印的*数量，每次扩大2倍
            for (int count = 0; count < MAGNIFICATION * row - 1; count++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
    
    /**
     * 打印平行四边形
     * @param height 此平面图形占据的行数目
     */
    public static void parallelogram(int height) {
        for (int row = 1; row <= height; row++) {
            for (int space = height - row; space > 0; space--) {
                System.out.print(" ");
            }
            int count = 2 * height - 1;
            while (count >= 0) {
                System.out.print("*");
                count--;
            }
            System.out.println();
        }
    }
}
